import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-03
 * Time:0:08
 */
class Student implements Comparable<Student>{
    String name;
    int age;
    double score;

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student student) {
        return (int)(this.score-student.score);
    }
}
public class TestDemo {
    public static void main(String[] args) {
        ArrayList<Student> arrayList=new ArrayList<>(3);
        arrayList.add(new Student("陈恋",18,100));
        arrayList.add(new Student("唐健",18,90));
        arrayList.add(new Student("喵喵",18,0));
      //  System.out.println(arrayList);
        Iterator<Student> it=arrayList.iterator();
        while(it.hasNext()){
            System.out.println(it.next()+" ");
        }
        System.out.println();
        Collections.sort(arrayList);
        System.out.println(arrayList);
    }
}
